<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>iic: xiic_low_level_eeprom_example.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="HTML_custom.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="xlogo_bg.gif"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">iic
   </div>
   <div id="projectbrief">Xilinx SDK Drivers API Documentation</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',false,false,'search.php','Search');
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('xiic__low__level__eeprom__example_8c.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">xiic_low_level_eeprom_example.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Overview</h2>
<div class="textblock"><p>This file consists of a polled mode design example which uses the Xilinx IIC device and low-level driver to exercise the EEPROM. </p>
<p>This example writes/reads from the lower 256 bytes of the IIC EEPROMS. Please refer to the datasheets of the IIC EEPROM's for details about the internal addressing and page size of these devices.</p>
<p>The <a class="el" href="group__iic__v3__1.html#ga907c577b53407fb0bfc98d0ca37ee221" title="Send data as a master on the IIC bus. ">XIic_Send()</a> API is used to transmit the data and <a class="el" href="group__iic__v3__1.html#ga7a848238d75ff57837afa5a58f11f326" title="Receive data as a master on the IIC bus. ">XIic_Recv()</a> API is used to receive the data.</p>
<p>This example is tested on ML300/ML310/ML403/ML501/ML507/ML510/ML605/SP601 and SP605 Xilinx boards.</p>
<p>The ML310/ML410/ML510 boards have a on-board 64 Kb serial IIC EEPROM (Microchip 24LC64A). The WP pin of the IIC EEPROM is hardwired to ground on this board.</p>
<p>The ML300 board has an on-board 32 Kb serial IIC EEPROM(Microchip 24LC32A). The WP pin of the IIC EEPROM has to be connected to ground for this example. The WP is connected to pin Y3 of the FPGA.</p>
<p>The ML403 board has an on-board 4 Kb serial IIC EEPROM(Microchip 24LC04A). The WP pin of the IIC EEPROM is hardwired to ground on this board.</p>
<p>The ML501/ML505/ML507/ML605/SP601/SP605 boards have an on-board 8 Kb serial IIC EEPROM(STM M24C08). The WP pin of the IIC EEPROM is hardwired to ground on these boards.</p>
<p>The AddressType for ML300/ML310/ML410/ML510 boards should be u16 as the address pointer in the on board EEPROM is 2 bytes.</p>
<p>The AddressType for ML403/ML501/ML505/ML507/ML605/SP601/SP605 boards should be u8 as the address pointer for the on board EEPROM is 1 byte.</p>
<p>The 7 bit IIC Slave address of the IIC EEPROM on the ML300/ML310/ML403/ML410/ ML501/ML505/ML507/ML510 boards is 0x50. The 7 bit IIC Slave address of the IIC EEPROM on the ML605/SP601/SP605 boards is 0x54. Refer to the User Guide's of the respective boards for further information about the IIC slave address of IIC EEPROM's.</p>
<p>The define EEPROM_ADDRESS in this file needs to be changed depending on the board on which this example is to be run.</p>
<p>This code assumes that no Operating System is being used.</p>
<dl class="section note"><dt>Note</dt><dd>None</dd></dl>
<pre>
MODIFICATION HISTORY:</pre><pre>Ver     Who  Date        Changes
<hr/>

1.00a jhl  09/10/03 Created
1.00a sv   05/09/05 Minor changes to comply to Doxygen and coding guidelines
1.00a mta  03/09/06 Minor updates due to changes in the low level driver for
              supporting repeated start functionality.
2.00a sdm  09/22/09 Converted all register accesses to 32 bit access and minor
              modifications as per coding guidelines.
2.01a ktn  03/17/10 Updated the information about the EEPROM's used on
              ML605/SP601/SP605 boards. Updated the example so that it
              can be used to access the entire IIC EEPROM for devices
              like M24C04/M24C08 that use LSB bits of the IIC device
              select code (IIC slave address) to specify the higher
              address bits of the EEPROM internal address.
2.01a sdm  06/13/11 Updated the example to flush the Tx FIFO when waiting for
              the previous command to be completed for CR612546.
3.4   ms   01/23/17 Added xil_printf statement in main function to
                    ensure that "Successfully ran" and "Failed" strings
                    are available in all examples. This is a fix for
                    CR-965028.
</pre> </div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a8db240f5cab3c37c56c8db4e0ad37ebd"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xiic__low__level__eeprom__example_8c.html#a8db240f5cab3c37c56c8db4e0ad37ebd">IicLowLevelEeprom</a> ()</td></tr>
<tr class="memdesc:a8db240f5cab3c37c56c8db4e0ad37ebd"><td class="mdescLeft">&#160;</td><td class="mdescRight">The function uses the low level driver of IIC to read and write to the IIC EEPROM board.  <a href="#a8db240f5cab3c37c56c8db4e0ad37ebd">More...</a><br /></td></tr>
<tr class="separator:a8db240f5cab3c37c56c8db4e0ad37ebd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad3c29e4ee8b1f6749a579636a178c069"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xiic__low__level__eeprom__example_8c.html#ad3c29e4ee8b1f6749a579636a178c069">ReadWriteVerify</a> (AddressType Address)</td></tr>
<tr class="memdesc:ad3c29e4ee8b1f6749a579636a178c069"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function writes, reads, and verifies the read to the IIC EEPROM.  <a href="#ad3c29e4ee8b1f6749a579636a178c069">More...</a><br /></td></tr>
<tr class="separator:ad3c29e4ee8b1f6749a579636a178c069"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a16a37ddca6337489a7c9deadddfc1547"><td class="memItemLeft" align="right" valign="top">unsigned&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xiic__low__level__eeprom__example_8c.html#a16a37ddca6337489a7c9deadddfc1547">EepromWriteByte</a> (AddressType Address, u8 *BufferPtr, u16 ByteCount)</td></tr>
<tr class="memdesc:a16a37ddca6337489a7c9deadddfc1547"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function writes a buffer of bytes to the IIC serial EEPROM.  <a href="#a16a37ddca6337489a7c9deadddfc1547">More...</a><br /></td></tr>
<tr class="separator:a16a37ddca6337489a7c9deadddfc1547"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5c87929a9d1ad69044b17cde4cf03c0a"><td class="memItemLeft" align="right" valign="top">unsigned&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xiic__low__level__eeprom__example_8c.html#a5c87929a9d1ad69044b17cde4cf03c0a">EepromReadByte</a> (AddressType Address, u8 *BufferPtr, u16 ByteCount)</td></tr>
<tr class="memdesc:a5c87929a9d1ad69044b17cde4cf03c0a"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function reads a number of bytes from the IIC serial EEPROM into a specified buffer.  <a href="#a5c87929a9d1ad69044b17cde4cf03c0a">More...</a><br /></td></tr>
<tr class="separator:a5c87929a9d1ad69044b17cde4cf03c0a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a840291bc02cba5474a4cb46a9b9566fe"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xiic__low__level__eeprom__example_8c.html#a840291bc02cba5474a4cb46a9b9566fe">main</a> (void)</td></tr>
<tr class="memdesc:a840291bc02cba5474a4cb46a9b9566fe"><td class="mdescLeft">&#160;</td><td class="mdescRight">Main function to call the low level EEPROM example.  <a href="#a840291bc02cba5474a4cb46a9b9566fe">More...</a><br /></td></tr>
<tr class="separator:a840291bc02cba5474a4cb46a9b9566fe"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a id="a5c87929a9d1ad69044b17cde4cf03c0a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5c87929a9d1ad69044b17cde4cf03c0a">&#9670;&nbsp;</a></span>EepromReadByte()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned EepromReadByte </td>
          <td>(</td>
          <td class="paramtype">AddressType&#160;</td>
          <td class="paramname"><em>Address</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8 *&#160;</td>
          <td class="paramname"><em>BufferPtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16&#160;</td>
          <td class="paramname"><em>ByteCount</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function reads a number of bytes from the IIC serial EEPROM into a specified buffer. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">Address</td><td>contains the address in the EEPROM to read from. </td></tr>
    <tr><td class="paramname">BufferPtr</td><td>contains the address of the data buffer to be filled. </td></tr>
    <tr><td class="paramname">ByteCount</td><td>contains the number of bytes in the buffer to be read. This value is not constrained by the page size of the device such that up to 64K may be read in one call.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The number of bytes read. A value less than the specified input value indicates an error.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None. </dd></dl>

<p class="reference">References <a class="el" href="group__iic__v3__1.html#gab28be58b11c65ecc54fc2f0c300412c1">XIic_ReadReg</a>.</p>

</div>
</div>
<a id="a16a37ddca6337489a7c9deadddfc1547"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a16a37ddca6337489a7c9deadddfc1547">&#9670;&nbsp;</a></span>EepromWriteByte()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned EepromWriteByte </td>
          <td>(</td>
          <td class="paramtype">AddressType&#160;</td>
          <td class="paramname"><em>Address</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8 *&#160;</td>
          <td class="paramname"><em>BufferPtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16&#160;</td>
          <td class="paramname"><em>ByteCount</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function writes a buffer of bytes to the IIC serial EEPROM. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">Address</td><td>contains the address in the EEPROM to write to. </td></tr>
    <tr><td class="paramname">BufferPtr</td><td>contains the address of the data to write. </td></tr>
    <tr><td class="paramname">ByteCount</td><td>contains the number of bytes in the buffer to be written. Note that this should not exceed the page size of the EEPROM as noted by the constant PAGE_SIZE.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The number of bytes written, a value less than that which was specified as an input indicates an error.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None. </dd></dl>

</div>
</div>
<a id="a8db240f5cab3c37c56c8db4e0ad37ebd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8db240f5cab3c37c56c8db4e0ad37ebd">&#9670;&nbsp;</a></span>IicLowLevelEeprom()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int IicLowLevelEeprom </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>The function uses the low level driver of IIC to read and write to the IIC EEPROM board. </p>
<p>The addresses tested are from 128 to 192.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">None.</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>XST_SUCCESS if successful, XST_FAILURE if unsuccessful.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None. </dd></dl>

<p class="reference">Referenced by <a class="el" href="xiic__low__level__eeprom__example_8c.html#a840291bc02cba5474a4cb46a9b9566fe">main()</a>.</p>

</div>
</div>
<a id="a840291bc02cba5474a4cb46a9b9566fe"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a840291bc02cba5474a4cb46a9b9566fe">&#9670;&nbsp;</a></span>main()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int main </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Main function to call the low level EEPROM example. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">None.</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>XST_SUCCESS if successful, XST_FAILURE if unsuccessful.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None. </dd></dl>

<p class="reference">References <a class="el" href="xiic__low__level__eeprom__example_8c.html#a8db240f5cab3c37c56c8db4e0ad37ebd">IicLowLevelEeprom()</a>.</p>

</div>
</div>
<a id="ad3c29e4ee8b1f6749a579636a178c069"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad3c29e4ee8b1f6749a579636a178c069">&#9670;&nbsp;</a></span>ReadWriteVerify()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int ReadWriteVerify </td>
          <td>(</td>
          <td class="paramtype">AddressType&#160;</td>
          <td class="paramname"><em>Address</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function writes, reads, and verifies the read to the IIC EEPROM. </p>
<p>It does the write as a single page write, performs a buffered read, and also performs byte reads.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">Address</td><td>is the starting address of the page in the EEPROM device to which the data is to be written.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>XST_FAILURE if the test fails, XST_SUCCESS if the test passes.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None. </dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Copyright &copy; 2015 Xilinx Inc. All rights reserved.</li>
  </ul>
</div>
</body>
</html>
